package com.lineage.data.item_etcitem.power;

import com.lineage.config.ConfigAlt;
import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_OwnCharStatus2;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class New_PanaceaCon extends ItemExecutor {
  private static final Log _log = LogFactory.getLog(New_PanaceaCon.class);
  
  private int type1;
  
  public static ItemExecutor get() {
    return new New_PanaceaCon();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (pc.getBaseCon() < ConfigAlt.POWERMEDICINE) {
      if (pc.getElixirStats() < ConfigAlt.MEDICINE + pc.getMeteLevel() * this.type1) {
        pc.addBaseCon(1);
        pc.setElixirStats(pc.getElixirStats() + 1);
        pc.getInventory().removeItem(item, 1L);
        pc.sendPackets((ServerBasePacket)new S_OwnCharStatus2(pc));
        try {
          pc.save();
        } catch (Exception e) {
          _log.error(e.getLocalizedMessage(), e);
        } 
      } else {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(79));
      } 
    } else {
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(481));
    } 
  }
  
  public void set_set(String[] set) {
    try {
      this.type1 = Integer.parseInt(set[1]);
    } catch (Exception exception) {}
  }
}
